<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>Bootstrap Admin Theme v3</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- jQuery UI -->
    <link href="https://code.jquery.com/ui/1.10.3/themes/redmond/jquery-ui.css" rel="stylesheet" media="screen">

    <!-- Bootstrap -->
    <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <!-- styles -->
    <link href="css/styles.css" rel="stylesheet">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
      
    <![endif]-->
     <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  </head>
 
  <body>
  	<div class="header">
	     <div class="container">
	        <div class="row">
	           <div class="col-md-5">
	              <!-- Logo -->
	              <div class="logo">
	                 <h1><a href="index.html">Bootstrap Admin Theme</a></h1>
	              </div>
	           </div>
	           <div class="col-md-5">
	              <div class="row">
	                <div class="col-lg-12">
	                  <div class="input-group form">
	                       <input type="text" class="form-control" placeholder="Search...">
	                       <span class="input-group-btn">
	                         <button class="btn btn-primary" type="button">Search</button>
	                       </span>
	                  </div>
	                </div>
	              </div>
	           </div>
	           <div class="col-md-2">
	              <div class="navbar navbar-inverse" role="banner">
	                  <nav class="collapse navbar-collapse bs-navbar-collapse navbar-right" role="navigation">
	                    <ul class="nav navbar-nav">
	                      <li class="dropdown">
	                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">My Account <b class="caret"></b></a>
	                        <ul class="dropdown-menu animated fadeInUp">
	                          <li><a href="profile.html">Profile</a></li>
	                          <li><a href="login.html">Logout</a></li>
	                        </ul>
	                      </li>
	                    </ul>
	                  </nav>
	              </div>
	           </div>
	        </div>
	     </div>
	</div>

    <div class="page-content">
    	<div class="row">
		  <div class="col-md-2">
		  	<div class="sidebar content-box" style="display: block;">
                <ul class="nav">
                    <!-- Main menu -->
                    <li><a href="index.html"><i class="glyphicon glyphicon-home"></i> Dashboard</a></li>
                    <li><a href="calendar.html"><i class="glyphicon glyphicon-calendar"></i> Calendar</a></li>
                    <li><a href="stats.html"><i class="glyphicon glyphicon-stats"></i> Statistics (Charts)</a></li>
                    <li><a href="table.html"><i class="glyphicon glyphicon-list"></i> Tables</a></li>
                    <li class="current"><a href="article.html"><i class="glyphicon glyphicon-list-alt"></i> Article</a></li>
                    <li><a href="buttons.html"><i class="glyphicon glyphicon-record"></i> Buttons</a></li>
                    <li><a href="editors.html"><i class="glyphicon glyphicon-pencil"></i> Editors</a></li>
                    <li><a href="forms.html"><i class="glyphicon glyphicon-tasks"></i> Forms</a></li>
                    <li class="submenu">
                         <a href="#">
                            <i class="glyphicon glyphicon-list"></i> Pages
                            <span class="caret pull-right"></span>
                         </a>
                         <!-- Sub menu -->
                         <ul>
                            <li><a href="login.html">Login</a></li>
                            <li><a href="signup.html">Signup</a></li>
                        </ul>
                    </li>
                </ul>
             </div>
		  </div>
		  <div class="col-md-10">

		  

  		

				

  			<div class="content-box-large">
  				<div class="panel-heading">
					<div class="panel-title">帖子管理</div>
				</div>
  				<div class="panel-body">
  					<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
						<thead>
							<tr>
	
							  <th>帖子序号</th>
			                  <th>帖子标题</th>
			                  <th>作者序号</th>
			                  <th>主题序号</th>
			                  <th>帖子置顶</th>
			                  <th>用户置顶</th>
			                  <th>创建时间</th>
			                  <th>最近修改时间</th>
			                  <th>操作</th>
							</tr>
						</thead>
						<tbody id="articlelist">
							<c:forEach items="${articles}" var="article" >
		                  <tr>
			             <td><a href="GetContentServlet?article_id=${article.article_id}">${article.article_id}</a></td>
			             <td>${article.article_title}</td>
			             <td>${article.user_id}</td>
			             <td>${article.theme_id}</td>
			              <td><c:choose>
			              <c:when test="${article.article_istop==0}">
			              <input type="checkbox" name = "istop" id = "istop" />
			              </c:when>
			              <c:when test="${article.article_istop==1}">
			              <input type="checkbox" name = "istop" id = "istop" checked= "checked" />
			              </c:when>
			              </c:choose></td>   
			            <!-- <td>${article.article_istop}</td>-->
                           <td><c:choose>
			              <c:when test="${article.article_user_istop==0}">
			              <input type="checkbox" name = "istop" id = "istop" />
			              </c:when>
			              <c:when test="${article.article_user_istop==1}">
			              <input type="checkbox" name = "istop" id = "istop" checked= "checked" />
			              </c:when>
			              </c:choose></td>  
			             <td>${article.article_createtime}</td>
			             <td>${article.article_lastchangetime}</td>
			            
			             
			             <td> 
			                            <button class="btn btn-success btn-xs" data-toggle="modal"
											data-target="#changeinformationModal">修改</button>
										<button class="btn btn-danger btn-xs" data-toggle="modal"
											data-target="#deleteModal">删除</button></td>
			             
		                 </tr>
	                       </c:forEach>
						</tbody>
					</table>
  				</div>
  			</div>

<!--弹出修改用户窗口-->
				<div class="modal fade" id="changeinformationModal" role="dialog"
					aria-labelledby="gridSystemModalLabel">
					<div class="modal-dialog" role="document">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal"
									aria-label="Close">
									<span aria-hidden="true">&times;</span>
								</button>
								<h4 class="modal-title" id="gridSystemModalLabel">修改帖子信息</h4>
							</div>
							<div class="modal-body">
								<div class="container-fluid">
									<form class="form-horizontal" method="GET"
										action="ChangeinformationServlet">
										<div class="form-group ">
											<label for="article_id" class="col-xs-3 control-label">文章序号：</label>
											<div class="col-xs-8 ">
												<input type="text" class="form-control input-sm duiqi" id="article_id"
													name="article_id" placeholder="" readonly="true">
											</div>
										</div>
										<div class="form-group">
											<label for="article_title" class="col-xs-3 control-label">帖子标题：</label>
											<div class="col-xs-8 ">
												<input type="" class="form-control input-sm duiqi" id="article_title" 
												name="article_title" placeholder="" >
											</div>
										</div>
										<div class="form-group">
											<label for="theme_id" class="col-xs-3 control-label">作者序号：</label>
											<div class="col-xs-8 ">
												<input type="" class="form-control input-sm duiqi" id="theme_id" 
												name="theme_id" placeholder="" >
											</div>
										</div>
										<div class="form-group">
											<label for="user_id" class="col-xs-3 control-label">用户序号：</label>
											<div class="col-xs-8 ">
												<input type="" class="form-control input-sm duiqi" id="user_id" 
												name="user_id" placeholder="" >
											</div>
										</div>

                                       <div class="form-group">
											<label for="article_istop" class="col-xs-3 control-label">文章置顶：</label>
											<div class="col-xs-8 ">
												<input type="" class="form-control input-sm duiqi" id="article_istop" 
												name="article_istop" placeholder="" >
											</div>
										</div>
										 <div class="form-group">
											<label for="article_user_istop" class="col-xs-3 control-label">用户置顶：</label>
											<div class="col-xs-8 ">
												<input type="" class="form-control input-sm duiqi" id="article_user_istop" 
												name="article_user_istop" placeholder="" >
											</div>
										</div>
									 <div class="form-group">
											<label for="article_createtime" class="col-xs-3 control-label">创建时间：</label>
											<div class="col-xs-8 ">
												<input type="" class="form-control input-sm duiqi" id="article_createtime" 
												name="article_createtime" placeholder="" >
											</div>
										</div>
										<div class="form-group">
											<label for="article_lastchangetime" class="col-xs-3 control-label">修改时间：</label>
											<div class="col-xs-8 ">
												<input type="" class="form-control input-sm duiqi" id="article_lastchangetime" 
												name="article_lastchangetime" placeholder="" >
											</div>
										</div> 	
										<div class="modal-footer">
											<button type="button" class="btn btn-xs btn-white"
												data-dismiss="modal">取消</button>
											<button type="submit" class="btn btn-xs btn-green">确定</button>
										</div>
									</form>
								</div>
							</div>
						</div>
						<!-- /.modal-content -->
					</div>
					<!-- /.modal-dialog -->
				</div>
				<!-- /.modal -->

							<!--删除帖子对话框-->
				<div class="modal fade" id="deleteModal" role="dialog"
					aria-labelledby="gridSystemModalLabel">

					<div class="modal-dialog" role="document">
						<div class="modal-content">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal"
									aria-label="Close">
									<span aria-hidden="true">&times;</span>
								</button>
								<h4 class="modal-title" id="gridSystemModalLabel">删除帖子！</h4>
							</div>
							<div class="modal-body">
								<div class="container-fluid">
									确定删除这条帖子吗?

										
								</div>
							</div>
							<div class="modal-footer">
								<button type="button" class="btn btn-xs btn-white"
												data-dismiss="modal">取消</button>
								<a href="" style="background-color:white"><button type="button" class="btn btn-xs btn-green" >确定</button></a>
							</div>

						</div>
						<!-- /.modal-content -->
					</div>
					<!-- /.modal-dialog -->
				</div>

		  </div>
		</div>
    </div>

    <footer>
         <div class="container">
         
            <div class="copy text-center">
               Copyright 2018 <a href='#'>Website</a>
            </div>
            
         </div>
      </footer>

      <link href="vendors/datatables/dataTables.bootstrap.css" rel="stylesheet" media="screen">

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://code.jquery.com/jquery.js"></script>
    <!-- jQuery UI -->
    <script src="https://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="bootstrap/js/bootstrap.min.js"></script>

    <script src="vendors/datatables/js/jquery.dataTables.min.js"></script>

    <script src="vendors/datatables/dataTables.bootstrap.js"></script>

    <script src="js/custom.js"></script>
    <script src="js/tables.js"></script>
    </script>
	<script type="text/javascript">
		$(function() {
			var article_id,article_title,user_id,theme_id,article_createtime,article_lastchangetime;
			$("#articlelist").on(
					"click",
					"button",
					function(event) {
						article_id = $(this).closest("tr").find("td").eq(
								0).text();
						article_title = $(this).closest("tr").find("td").eq(
								1).text();
						user_id = $(this).closest("tr").find("td").eq(
								2).text();
						theme_id = $(this).closest("tr").find("td").eq(
								3).text();
						//article_istop = $(this).closest("tr").find("td").eq(
						//		4).text();
						article_createtime = $(this).closest("tr").find("td").eq(
								6).text();
						article_lastchangetime = $(this).closest("tr").find("td").eq(
								7).text();
						console.log(article_id);
						console.log(article_title);
						console.log(user_id);
						console.log(theme_id);
						//console.log(article_istop);
						console.log(article_createtime);
						console.log(article_lastchangetime);
						
					});
			$('#deleteModal').on('show.bs.modal',function(){
			$(this).find("a").attr("href","DeleteArticleServet?article_id="+article_id);
			});
			$("#changeinformationModal").on('show.bs.modal', function() {
				$(this).find("#article_id").val(article_id);
				$(this).find("#article_title").val(article_title);
				$(this).find("#user_id").val(user_id);
				$(this).find("#theme_id").val(theme_id);
				//$(this).find("#article_istop").val(article_istop);
				$(this).find("#article_createtime").val(article_createtime);
				$(this).find("#article_lastchangetime").val(article_lastchangetime);
			})
	
		})

	</script>
  </body>
</html>